package com.run_java_test.test_run;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dynamic")
public class DynamicControllerEndpoint {

    @Autowired
    private DynamicControllerManager dynamicControllerManager;

    @PostMapping("/uploadController")
    public String uploadController(@RequestParam String sourceCodePath, @RequestParam String className) {
        boolean success = dynamicControllerManager.addOrUpdateController(sourceCodePath, className);
        return success ? "Controller uploaded and updated successfully!" : "Failed to upload or update controller.";
    }
}